package cn.xluobo.business.wechat.miniapp.course.service;

import cn.xluobo.business.sc.course.domain.req.time.ReqSearchScClaTimeAttend;
import cn.xluobo.business.sc.course.domain.resp.time.RespClaTimeAttend;
import cn.xluobo.business.sc.course.repo.mapper.ScClaTimeAttendMapper;
import cn.xluobo.config.login.LoginUser;
import cn.xluobo.core.page.RespPage;
import cn.xluobo.utils.LoginUserUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author ：KingLong
 * @date ：Created in 2020/11/11 20:34
 */
@Service
public class WechatMiniClaTimeAttendService {

    @Autowired
    private ScClaTimeAttendMapper attendMapper;

    /**
     * 查询
     *
     * @param reqSearchScClaTimeAttend
     * @return
     */
    public RespPage<RespClaTimeAttend> searchAttendList(ReqSearchScClaTimeAttend reqSearchScClaTimeAttend) {
        LoginUser loginUser = LoginUserUtil.getLoginUser();
        Long deptId = loginUser.getDeptId();

        reqSearchScClaTimeAttend.setTenantId(loginUser.getNowTenantId());
        reqSearchScClaTimeAttend.setDeptId(deptId);
        reqSearchScClaTimeAttend.setUserId(loginUser.getUserId());

        RespPage<RespClaTimeAttend> page = new RespPage(reqSearchScClaTimeAttend.getPageNum(), reqSearchScClaTimeAttend.getPageSize());
        List<RespClaTimeAttend> attendList = attendMapper.selectTimeAttendList(reqSearchScClaTimeAttend, page);
        page.setRows(attendList);
        return page;
    }
}
